<template>
	<view>
		<view class="banner">
			<image src="https://jsgl.zfcxjw.cq.gov.cn:28082/prod-api/profile/upload/2025/06/18/img1_20250618123903A814.png" mode="widthFix" class="img"></image>
		</view>
		<view class="page-column" v-if="projectInfo.id">
			<view class="title">实名制管理</view>
			<view class="list">
				<view class="item" @tap="toRosterRegisetr">
					<image src="https://jsgl.zfcxjw.cq.gov.cn:28082/prod-api/profile/upload/2025/06/21/img2_20250621080259A251.png" class="icon"></image>
					<view class="sp">人员登记</view>
				</view>
				<view class="item" @tap="toRoster">
					<image src="https://jsgl.zfcxjw.cq.gov.cn:28082/prod-api/profile/upload/2025/06/21/img3_20250621080359A252.png" class="icon"></image>
					<view class="sp">花名册</view>
				</view>
				<view class="item" @tap="toAttendance">
					<image src="https://jsgl.zfcxjw.cq.gov.cn:28082/prod-api/profile/upload/2025/06/21/img4_20250621080639A253.png" class="icon"></image>
					<view class="sp">移动考勤</view>
				</view>
				<view class="item" @tap="toAttendanceFlow">
					<image src="https://jsgl.zfcxjw.cq.gov.cn:28082/prod-api/profile/upload/2025/06/21/img5_20250621080725A254.png" class="icon"></image>
					<view class="sp">考勤流水</view>
				</view>
				<view class="item" @tap="toProjectSurvey">
					<image src="https://jsgl.zfcxjw.cq.gov.cn:28082/prod-api/profile/upload/2025/06/25/img6_20250625112012A766.png" class="icon"></image>
					<view class="sp">实时概况</view>
				</view>
				<view class="item" @tap="toRosterInspection">
					<image src="https://jsgl.zfcxjw.cq.gov.cn:28082/prod-api/profile/upload/2025/06/21/img7_20250621080753A255.png" class="icon"></image>
					<view class="sp">人员巡检</view>
				</view>
			</view>
		</view>

		<view style="text-align: center" v-else>
			<image
				src="https://jsgl.zfcxjw.cq.gov.cn:28082/prod-api/profile/upload/2025/06/16/b8e92001ef427b77c51f7decc8c929f_20250616111639A414.png"
				mode="widthFix"
				style="width: 90%"
			></image>
			<view style="position: relative; top: -100rpx">暂无权限，请联系项目管理人员开通！</view>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue';
import { onShow, onLoad } from '@dcloudio/uni-app';
const projectInfo = ref({}); // 项目信息
let authCode = ref(''); //平台提供的权限码
function toRosterRegisetr() {
	//人员登记
	if (!verifyAuthCode()) return;
	uni.navigateTo({
		url: '/pagesA/pages/roster/register/register'
	});
}
function toRoster() {
	//花名册
	if (!verifyAuthCode()) return;
	uni.navigateTo({
		url: '/pagesA/pages/roster/roster'
	});
}
function toAttendance() {
	//移动考勤
	if (!verifyAuthCode()) return;
	uni.navigateTo({
		url: '/pagesA/pages/attendance/check/position'
	});
}
function toAttendanceFlow() {
	//考勤流水
	if (!verifyAuthCode()) return;
	uni.navigateTo({
		url: '/pagesA/pages/attendanceFlow/attendanceFlow'
	});
}
function toProjectSurvey() {
	//实时概况
	if (!verifyAuthCode()) return;
	uni.navigateTo({
		url: '/pagesA/pages/projectSurvey/projectSurvey'
	});
}
function toRosterInspection() {
	//人员巡检
	if (!verifyAuthCode()) return;
	uni.navigateTo({
		url: '/pagesA/pages/personnelInspection/personnelInspection'
	});
}
function verifyAuthCode() {
	if (!authCode.value) {
		uni.showToast({
			title: '未获取到用户信息',
			icon: 'none'
		});
		return false;
	}
	return true;
}

onLoad((option) => {});

onShow(() => {
	projectInfo.value = uni.getStorageSync('activeProject') || {};
	uni.setNavigationBarTitle({
		title: projectInfo.value.name || '工地'
	});
	authCode.value = uni.getStorageSync('authCode') || '';
	if (uni.getStorageSync('cisdiAuthCode') != authCode.value) {
		//authCode发生变化
		uni.removeStorageSync('cisdiAccessToken');
		uni.removeStorageSync('cisdiRefreshToken');
	}
	uni.setStorageSync('cisdiAuthCode', authCode.value);
});
</script>

<style lang="less">
page {
	background: #f8f8f8;
}
.banner {
	padding: 30rpx;
	.img {
		width: 100%;
		display: block;
	}
}
.page-column {
	padding: 20rpx 10rpx;
	background: #fff;
	margin-bottom: 30rpx;
	.title {
		height: 40rpx;
		line-height: 40rpx;
		font-size: 32rpx;
		padding: 0 20rpx;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
	}
	.list {
		.item {
			width: 22.75%;
			font-size: 0;
			text-align: center;
			display: inline-block;
			margin: 30rpx 3% 0 0;
			.icon {
				width: 60rpx;
				height: 60rpx;
				background: #ecf5ff;
				padding: 30rpx;
				border-radius: 5px;
			}
			.sp {
				height: 40rpx;
				line-height: 40rpx;
				margin-top: 20rpx;
				font-size: 28rpx;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}
		}
		.item:nth-child(4n) {
			margin-right: 0;
		}
	}
}
</style>